<script lang="ts" setup>
import { useMemberStore } from '@/stores/modules/memberStore';

const memberStore = useMemberStore();

// 注销登录
const logout = () => {
  uni.showModal({
    content: '是否退出登录？',
    success({ confirm }) {
      if (confirm) {
        memberStore.clearProfile();
        uni.navigateBack();
      }
    },
  });
};
</script>

<template>
  <view class="viewport">
    <!-- 收货地址管理 -->
    <view class="list" v-if="memberStore.profile">
      <navigator class="item arrow" url="/pagesMember/address/address" hover-class="none">我的收货地址</navigator>
    </view>
    <!-- 其它设置项 -->
    <view class="list">
      <button hover-class="none" class="item arrow" open-type="openSetting">授权管理</button>
      <button hover-class="none" class="item arrow" open-type="feedback">问题反馈</button>
      <button hover-class="none" class="item arrow" open-type="contact">联系我们</button>
    </view>
    <!-- 关于 -->
    <view class="list">
      <view class="item arrow">关于小兔鲜儿</view>
    </view>
    <!-- 操作 -->
    <view class="action" v-if="memberStore.profile">
      <view class="button" @tap="logout">退出登录</view>
    </view>
  </view>
</template>

<style lang="scss">
.viewport {
  width: 100vw;
  height: 100vh;
  padding: 20rpx;
  background-color: #f4f4f4;

  .list {
    padding: 0 20rpx;
    background-color: #fff;
    margin-bottom: 20rpx;
    border-radius: 10rpx;

    .item {
      line-height: 90rpx;
      padding-left: 10rpx;
      font-size: 30rpx;
      color: #333;
      border-top: 1rpx solid #ddd;
      position: relative;
      text-align: left;
      border-radius: 0;
      background-color: #fff;

      &::after {
        width: auto;
        height: auto;
        left: auto;
        right: 5rpx;
        border: none;
      }

      &:first-child {
        border: none;
      }
    }

    .arrow::after {
      content: '\e6c2';
      position: absolute;
      top: 50%;
      color: #333;
      font-family: 'erabbit' !important;
      font-size: 32rpx;
      transform: translateY(-50%);
    }
  }
}

.action {
  text-align: center;
  line-height: 90rpx;
  margin-top: 40rpx;
  font-size: 32rpx;
  color: #333;

  .button {
    color: white;
    background-color: #27ba9b;
    margin-bottom: 20rpx;
    border-radius: 10rpx;
  }
}
</style>